/*
 * JDialogInserirJogador.java
 *  Copyright (C) 2008  Tiago Silva Loureiro
 *  This File is part of Bier Manager.
 *  Bier Manager is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 * 
 * Created on 26 de Setembro de 2008, 19:00
 */

package biermanager.editorDeTimes.interfaceGrafica;

import biermanager.editorDeTimes.uteis.LimitaEdits;
import biermanager.nucleo.Jogador;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;

/**
 *
 * @author  tiagoloureiro
 */
public class JDialogInserirJogador extends javax.swing.JDialog {
    private Jogador jogador;

    /** Creates new form JDialogInserirJogador
     * @param parent
     * @param modal 
     */
    public JDialogInserirJogador(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();  
        setLocation( (int)( ( screenSize.getWidth() - this.getWidth() ) / 2 ), (int)( (screenSize.getHeight() - this.getHeight() - 40) / 2 ) );
    
    }
        public JDialogInserirJogador(java.awt.Frame parent, boolean modal, Jogador jogadorDeEntrada ) {
        super(parent, modal);
        initComponents();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();  
        setLocation( (int)( ( screenSize.getWidth() - this.getWidth() ) / 2 ), (int)( (screenSize.getHeight() - this.getHeight() - 40) / 2 ) );
        jtfNomeDoJogador.setText( jogadorDeEntrada.getNome() );
        
        if( jogadorDeEntrada.getCraque() )
            jcbCraque.setSelectedIndex(1);
        else
            jcbCraque.setSelectedIndex(0);
        
        jspForca.setValue( jogadorDeEntrada.getForca() );
        jslAgressividade.setValue( jogadorDeEntrada.getAgressividade() );
        jcbPosicao.setSelectedItem( jogadorDeEntrada.getPosicao() );
        jspVelocidade.setValue(jogadorDeEntrada.getVelocidade());
        jspHabilidade.setValue(jogadorDeEntrada.getHabilidade());
        jspResistencia.setValue(jogadorDeEntrada.getResistencia());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jcbCraque = new javax.swing.JComboBox();
        jspForca = new javax.swing.JSpinner();
        jslAgressividade = new javax.swing.JSlider();
        jtfNomeDoJogador = new javax.swing.JTextField();
        jcbPosicao = new javax.swing.JComboBox();
        jlNomeDoJogador = new javax.swing.JLabel();
        jlPosicaoDoJogador = new javax.swing.JLabel();
        jlCraque = new javax.swing.JLabel();
        jlForca = new javax.swing.JLabel();
        jlAgressividade = new javax.swing.JLabel();
        jlAtributo = new javax.swing.JLabel();
        jspVelocidade = new javax.swing.JSpinner();
        jlVelocidade = new javax.swing.JLabel();
        jlResistencia = new javax.swing.JLabel();
        jspResistencia = new javax.swing.JSpinner();
        jspHabilidade = new javax.swing.JSpinner();
        jlHabilidade = new javax.swing.JLabel();
        jbutCancelar = new javax.swing.JButton();
        jbutInserirJogador = new javax.swing.JButton();
        jlNomeDoJogador1 = new javax.swing.JLabel();
        jspNumeroDaCamisa = new javax.swing.JSpinner();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Adicionar Jogador ao Plantel");
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setModal(true);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jcbCraque.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Não é Craque!", "Craque de Bola" }));
        jcbCraque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcbCraqueActionPerformed(evt);
            }
        });

        jspForca.setModel(new javax.swing.SpinnerNumberModel(12, 1, 99, 1));
        jspForca.setToolTipText("Insira o valor da força desse jogador");
        jspForca.setEditor(new javax.swing.JSpinner.NumberEditor(jspForca, ""));

        jslAgressividade.setMajorTickSpacing(1);
        jslAgressividade.setMaximum(10);
        jslAgressividade.setMinimum(1);
        jslAgressividade.setPaintLabels(true);
        jslAgressividade.setPaintTicks(true);
        jslAgressividade.setToolTipText("Insira o nível de agressividade desse jogador");
        jslAgressividade.setValue(5);

        jtfNomeDoJogador.setDocument( new LimitaEdits( 20 ));

        jcbPosicao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Goleiro", "Fixo", "Ala esquerdo", "Ala direito", "Pivô de referência", "Pivô de movimentação" }));

        jlNomeDoJogador.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jlNomeDoJogador.setLabelFor(jtfNomeDoJogador);
        jlNomeDoJogador.setText("Nome do Jogador");

        jlPosicaoDoJogador.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jlPosicaoDoJogador.setLabelFor(jcbPosicao);
        jlPosicaoDoJogador.setText("Posição do Jogador");

        jlCraque.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jlCraque.setLabelFor(jcbPosicao);
        jlCraque.setText("Craque?");

        jlForca.setText("Força ");

        jlAgressividade.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jlAgressividade.setLabelFor(jslAgressividade);
        jlAgressividade.setText("Agressividade do Jogador");

        jlAtributo.setText("<html><b>Atributos do Jogador");

        jspVelocidade.setModel(new javax.swing.SpinnerNumberModel(12, 1, 99, 1));
        jspVelocidade.setToolTipText("Insira o valor da força desse jogador");
        jspVelocidade.setEditor(new javax.swing.JSpinner.NumberEditor(jspVelocidade, ""));

        jlVelocidade.setText("Velocidade ");

        jlResistencia.setText("Resistência");

        jspResistencia.setModel(new javax.swing.SpinnerNumberModel(12, 1, 99, 1));
        jspResistencia.setToolTipText("Insira o valor da força desse jogador");
        jspResistencia.setEditor(new javax.swing.JSpinner.NumberEditor(jspResistencia, ""));

        jspHabilidade.setModel(new javax.swing.SpinnerNumberModel(12, 1, 99, 1));
        jspHabilidade.setToolTipText("Insira o valor da força desse jogador");
        jspHabilidade.setEditor(new javax.swing.JSpinner.NumberEditor(jspHabilidade, ""));

        jlHabilidade.setText("Habilidade");

        jbutCancelar.setText("Cancelar");
        jbutCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbutCancelarActionPerformed(evt);
            }
        });

        jbutInserirJogador.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jbutInserirJogador.setText("Inserir Jogador");
        jbutInserirJogador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbutInserirJogadorActionPerformed(evt);
            }
        });

        jlNomeDoJogador1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jlNomeDoJogador1.setLabelFor(jtfNomeDoJogador);
        jlNomeDoJogador1.setText("Número da Camisa");

        jspNumeroDaCamisa.setModel(new javax.swing.SpinnerNumberModel(12, 1, 99, 1));
        jspNumeroDaCamisa.setToolTipText("Insira o valor da força desse jogador");
        jspNumeroDaCamisa.setEditor(new javax.swing.JSpinner.NumberEditor(jspNumeroDaCamisa, ""));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jlNomeDoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jlPosicaoDoJogador, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jslAgressividade, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE)
                            .addComponent(jtfNomeDoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jlAgressividade, javax.swing.GroupLayout.DEFAULT_SIZE, 192, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jcbPosicao, 0, 140, Short.MAX_VALUE)
                            .addComponent(jcbCraque, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jlCraque, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(59, 59, 59)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNomeDoJogador1, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                            .addComponent(jlAtributo, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jlHabilidade, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jlResistencia, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                                    .addComponent(jlForca, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jlVelocidade, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jspForca, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jspResistencia, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jspVelocidade, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jspHabilidade, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jspNumeroDaCamisa, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(60, 60, 60)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jbutCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbutInserirJogador, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlNomeDoJogador)
                            .addComponent(jlPosicaoDoJogador)
                            .addComponent(jlNomeDoJogador1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfNomeDoJogador, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jcbPosicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jspNumeroDaCamisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jlCraque)
                            .addComponent(jlAtributo)
                            .addComponent(jlAgressividade, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jcbCraque, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jlForca)
                                    .addComponent(jspForca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jlVelocidade)
                                    .addComponent(jspVelocidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jlResistencia)
                                    .addComponent(jspResistencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jlHabilidade)
                                    .addComponent(jspHabilidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addComponent(jslAgressividade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jbutCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jbutInserirJogador, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
private void jbutCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbutCancelarActionPerformed
            if (JOptionPane.showConfirmDialog(null, "Deseja finalizar sem adicionar o jogador?","Editor de Times - Bier Manager", JOptionPane.YES_NO_OPTION ) == JOptionPane.OK_OPTION )
            this.dispose();
}//GEN-LAST:event_jbutCancelarActionPerformed

private void jbutInserirJogadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbutInserirJogadorActionPerformed
            if( verificaPreenchimento() ){
                String nome = "";
                int forca = 0;
                int velocidade = 0;
                int resistencia = 0;
                int habilidade = 0;
                int numeroDaCamisa = 0;
                String posicao = "";
                int agressividade = 0;
                boolean craque = false;
                nome = jtfNomeDoJogador.getText();
                if( jcbCraque.getSelectedIndex() == 0 )
                    craque = false;
                else
                    craque = true;
                posicao = (String)jcbPosicao.getSelectedItem();
                forca = (Integer)jspForca.getValue();
                resistencia = (Integer)jspResistencia.getValue();
                habilidade = (Integer)jspHabilidade.getValue();
                velocidade = (Integer)jspVelocidade.getValue();
                agressividade = jslAgressividade.getValue();
                numeroDaCamisa = (Integer)jspNumeroDaCamisa.getValue();
                jogador = new Jogador( nome, forca, velocidade, resistencia, habilidade, posicao, numeroDaCamisa, agressividade, craque);
                this.dispose();
            }
}//GEN-LAST:event_jbutInserirJogadorActionPerformed

private void jcbCraqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbCraqueActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jcbCraqueActionPerformed

public Jogador getJogador(){
    return(this.jogador);
}

private boolean verificaPreenchimento(){
    if( !(jtfNomeDoJogador.getText().isEmpty()) && jtfNomeDoJogador.getText().length() > 4 && jtfNomeDoJogador.getText().length() < 21 ){
            return(true);
    }
    else{
       JOptionPane.showMessageDialog(null, "O campo Nome do Jogador deve estar preenchido e conter entre 5 e 20 caracteres!");
       return(false);
    }
}

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JButton jbutCancelar;
    private javax.swing.JButton jbutInserirJogador;
    private javax.swing.JComboBox jcbCraque;
    private javax.swing.JComboBox jcbPosicao;
    private javax.swing.JLabel jlAgressividade;
    private javax.swing.JLabel jlAtributo;
    private javax.swing.JLabel jlCraque;
    private javax.swing.JLabel jlForca;
    private javax.swing.JLabel jlHabilidade;
    private javax.swing.JLabel jlNomeDoJogador;
    private javax.swing.JLabel jlNomeDoJogador1;
    private javax.swing.JLabel jlPosicaoDoJogador;
    private javax.swing.JLabel jlResistencia;
    private javax.swing.JLabel jlVelocidade;
    private javax.swing.JSlider jslAgressividade;
    private javax.swing.JSpinner jspForca;
    private javax.swing.JSpinner jspHabilidade;
    private javax.swing.JSpinner jspNumeroDaCamisa;
    private javax.swing.JSpinner jspResistencia;
    private javax.swing.JSpinner jspVelocidade;
    private javax.swing.JTextField jtfNomeDoJogador;
    // End of variables declaration//GEN-END:variables

}
